home *** CD-ROM | disk | FTP | other *** search
/ Aminet 31 / Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso / Aminet / comm / misc / MakeFTPScript.lha / MakeFTPScript / ARexx / CheckFTPScript.rexx next >
Encoding:
OS/2 REXX Batch file  |  1999-03-19  |  2.8 KB  |  139 lines

  1. /* CheckFTPScript v1.7 by Grzegorz Fitrzyk SP9WUN (domagal@uci.agh.edu.pl)
  2.    
  3.  
  4.    usage:    rx rexx:CheckFTPScript.rexx SOURCE/K DEST/K DIR/K
  5.    ex.:      rx rexx:CheckFTPScript.rexx ram:script ram:script_new ram:download
  6.  
  7. */
  8.  
  9.  
  10. parse arg source destin direct
  11. header='#MKFTP1'
  12.  
  13. dire=pos(right(direct,1),'/')
  14. dir2=pos(right(direct,1),':')
  15. dirl=length(direct)
  16. extd='/'
  17. indsw=0
  18. indsw2=0
  19.  
  20. if dire~=0 then direct=left(direct,dirl-1)
  21. if dir2~=0 then extd=''
  22. indsw=1
  23. sourceind=source||'.idx'
  24.  
  25. MODE=''
  26. miss=0
  27. trn=0
  28. totsize=0
  29. nsize=0
  30.  
  31. options results
  32.  
  33. say
  34. say 'Please wait, checking directory.'
  35. say
  36. say 'Missed files:'
  37. say
  38.  
  39. address command 'list 'direct||extd'#? files >t:list_temp'
  40.  
  41. if Open(loadit, source, 'Read') then do    /* Open source file.*/
  42.   if Open(Saveit, destin, 'Write') then do /* Open destination file. */
  43.     call writeln(Saveit,header)
  44.     do forever
  45.       line=Readln(loadit)
  46.       if line="" then leave
  47.       call makeline
  48.     end
  49.   end; else call error_write
  50. end; else call error_read
  51.  
  52. say
  53. say 'Total number of losted files: 'miss
  54. say 'Total losted kbytes: 'totsize
  55. say
  56.  
  57. quitit:
  58. call close(saveit)
  59. call close(loadit)
  60. address command 'delete t:list_temp force quiet'
  61. address command 'c:filenote 'destin' 'totsize'KB'
  62. exit
  63.  
  64. error_read:
  65. say 'Cant find source file: 'source
  66. call quitit
  67.  
  68. error_write:
  69. say 'Cant write destination file 'dest
  70. call quitit
  71.  
  72. makeline:
  73. parse var line nctemp " " ncaddr ":" rest "#" size
  74. parse var rest xrest '    '
  75. rest=xrest
  76. do while tt~=0
  77.   parse var rest "/" fname '0a'x
  78.   tt=pos('/',fname)
  79.   rest=fname
  80. end
  81. tt=5
  82. call open(loadit2,'t:list_temp',read)
  83. fin=0
  84. csize=0
  85. do while rt~=""
  86.   rt=readln(loadit2)
  87.   parse var rt rts rsize rrest        /* czytaj liste plików z dysku */
  88.   if (rts~="Directory" & rts~=":") then do
  89.     if rest=rts then do            /* czy plik w skrypcie (rest) jest zapisany na dysku (rts) */
  90.       fin=1
  91.       rrsize=rsize
  92.     end
  93.   end
  94. end
  95. csize=0
  96. if (rrsize='empty' | rrsize='' | rrsize='files') then rrsize=0
  97. rrsize=translate(rrsize,,' ')
  98. call getind
  99.  
  100. call close(loadit2)
  101. rt="."
  102. return
  103.  
  104. writedest:
  105. call writeln(saveit,line)
  106. if pos('.readme',fname)=0 then do
  107.   say fname||' less: '||(nsize-csize)||'kB'
  108. end; else do
  109.   say fname
  110. end
  111. miss=miss+1
  112. return
  113.  
  114. getind:
  115. if pos('.readme',rest)=0 then do    /* nie jest to plik Readme */
  116.    if fin=1 then do
  117.      lrsize=length(rrsize)
  118.      if (lrsize-3)<1 then lrsize=4
  119.      numeric digits (lrsize-3)
  120.      csize=(rrsize/1023)        /* wielkoôê pliku odczytanego z dysku */
  121.      numeric digits 10
  122.    end
  123.    size=translate(size,,' ')
  124.    nsize=size
  125.    if nsize>csize then do        /* czy wielkoôê z indeksu > od wielkoôci z dysku */
  126.      call writedest
  127.      trn=trn+1                /* licznik uszkodz. plików +1 */
  128.      totsize=totsize+(nsize-csize)
  129.    end
  130.    call close(loadind)
  131. end; else do
  132.    if fin~=1 then do
  133.      nsize=0
  134.      csize=0
  135.      call writedest
  136.    end
  137. end
  138. return
  139.